# Maintainer: Ray Griffin <rorgoroth-dev@outlook.com>

_realname=jpegoptim
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.5.5
pkgrel=1
pkgdesc="Utility to optimize jpeg files (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32' 'clangarm64')
url="https://github.com/tjko/jpegoptim/"
license=('spdx:GPL-3.0-or-later')
depends=("${MINGW_PACKAGE_PREFIX}-libjpeg-turbo")
makedepends=("${MINGW_PACKAGE_PREFIX}-autotools"
             "${MINGW_PACKAGE_PREFIX}-cc")
source=(${_realname}-${pkgver}.tar.gz::https://github.com/tjko/jpegoptim/archive/refs/tags/v${pkgver}.tar.gz)
sha256sums=('90a309d1c092de358bb411d702281ac3039b489d03adb0bc3c4ef04cf0067d38')
validpgpkeys=('9168CD7A2F0AAB0679D09BBA9D08A80CED908D6A') # Timo Kokkonen <tjko@iki.fi>

build() {
  cd "${_realname}-${pkgver}"

  ./configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST}

  make
}

package() {
  cd "${_realname}-${pkgver}"
  make install DESTDIR="${pkgdir}"

  install -Dm644 "${srcdir}/${_realname}-${pkgver}/LICENSE" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE"
}
